In digital signal processing, floating point operations have an advantage that highly accurate operations are possible even when the range of the value of signal data to be handled is large but have a problem that a complicated circuit is required and therefore the circuit scale and power consumption are large. Further, fixed point operations have an advantage that a circuit is simple and the circuit scale and power consumption are small but have a problem that the accuracy of operations is low.
On the other hand, as an operation method that has advantages of both floating point and fixed point, there are block floating point operations. In the block floating point operations, a plurality of signal data are grouped into one block, and normalization is performed for the entire block to have a common exponent in each block.
Specifically, in the block floating point processing, the normalization of a block floating point is performed in the following steps.
(1) Calculate the maximum exponent of all data in the block.
(2) Shift (normalize) the entire block by the calculated maximum exponent.
The maximum exponent is the largest exponent that does not cause overflow of all data in the block. The maximum exponent is equal to the exponent value of data with the largest absolute value among all data in the block.
As a method of efficiently calculating the maximum exponent, the following method is known (see Patent Literature 1, for example).
(1) Calculate the absolute values of data in the block.
(2) Calculate the logical OR of the absolute values of the data.
(3) Detect the bit position on the MSB (Most Significant Bit) side of the calculated logical OR and determine the maximum exponent.
A specific example of the normalization of a block floating point using the above-described method of calculating the maximum exponent is described hereinbelow.
First, consider a block composed of eight data, input data 1 to input data 8, which are eight-bit input data shown below, as a block to be normalized. In the following, the value of each data is represented by two's complement. Note that, in the bit string of the data shown hereinbelow, the leftmost bit is MSB, and the rightmost bit is LSB. The MSB is a sign bit.
Input data 1: 00010111
Input data 2: 00110001
Input data 3: 00000110
Input data 4: 11110011
Input data 5: 11111000
Input data 6: 00000110
Input data 7: 00001011
Input data 8: 00011011
Next, calculate the absolute values of the data (the input data 1 to 8) in the block. The absolute values of the input data 1 to 8 are hereinafter referred to as the absolute values 1 to 8. Specifically, the absolute value of input data k is referred to as the absolute value k (k is a positive integer of any one of 1 to 8.).
Absolute value 1: 00010111
Absolute value 2: 00110001
Absolute value 3: 00000110
Absolute value 4: 00001101
Absolute value 5: 00001000
Absolute value 6: 00000110
Absolute value 7: 00001011
Absolute value 8: 00011011
Then, calculate the logical OR of the calculated absolute values. The logical OR of the absolute values 1 to 8 is shown below.
Logical OR: 00111111
Then, detect the 5th bit as the bit position where the value of the bit first becomes 1 when viewed from the MSB (Most Significant Bit) side of the calculated logical OR. Assume that the MSB is the 7th bit, and the LSB (Least Significant Bit) is the 0th bit. In the case of bit shifting the input data 1 to 8 to the left by the same shift amount in order to normalize the input data 1 to 8 by a common exponent, if the shift amount is one bit, the normalized value is accurately represented, with any signs of the input data 1 to 8 remaining unchanged. Thus, the maximum exponent is −1.
Finally, normalize all data (the input data 1 to 8) in the group based on the calculated maximum exponent and determine the normalized data (normalized data 1 to 8). Specifically, when the maximum exponent is −1, shift the data to the left by one bit. Data after normalization of the input data 1 to 8 are referred to hereinafter as the normalized data 1 to 8. Thus, data after normalization of the input data k is referred to as the normalized data k (k is a positive integer of any one of 1 to 8.). Because the maximum exponent is −1, the actual value of the normalized data 1 to 8 is the value obtained by multiplying each data by the −1th power of 2.
Normalized data 1: 00101110
Normalized data 2: 01100010
Normalized data 3: 00001100
Normalized data 4: 11100110
Normalized data 5: 11110000
Normalized data 6: 00001100
Normalized data 7: 00010110
Normalized data 8: 00110110
In the above-described normalization process, it is necessary to calculate the absolute values of the data in the block in the step of calculating the maximum exponent. In order to convert negative data into positive data in the calculation of the absolute values, it is necessary to execute processing such as bit inversion, addition of 1, and carry when adding 1. There is thus a problem that the process of calculating the absolute values takes time. Further, because a circuit for executing such processing is needed, there is a problem that the circuit scale and power consumption are large.
Further, in the block floating point processing, it is necessary to repeatedly calculate the absolute values a plurality of times corresponding to the number of data constituting the block. Therefore, in the above-described normalization process, processing time to repeat the calculation of the absolute values which takes time increases drastically.
As described above, the above-described normalization process has a problem that the calculation of the maximum exponent cannot be done at high speed and the circuit scale and power consumption are large.
Further, the above-described normalization process has a problem that it is necessary to process the maximum value on the negative side in an exceptional manner or not to use the maximum value on the negative side. This is because, in the case of X-bit data, while the maximum value on the negative side of the data is −1× (the (X−1)th power of 2), +1× (the (X−1)th power of 2), which is the absolute value of the same data, cannot be represented by X bits (X is a positive integer). Note that x is a multiplication sign.
Specifically, in the case of 8-bit data, while the maximum value on the negative side of the data is −1× (the 7th power of 2)=−128, +1× (the 7th power of 2)=+128, which is the absolute value of the same data, cannot be represented by 8 bits, and 9 bits are necessary. Therefore, there is a problem that, when the value of data is −128, it is necessary to process −128 in an exceptional manner, such as saturating the absolute value +128 to +127, or not to use −128.
Note that Patent Literature 2 discloses the 1-position detecting method that sequentially computes the value of each bit using mask data to extract data for determining a value per bit of data indicating the position where the bit is 1 in input data. Patent Literature 2 discloses that, according to the 1-position detecting method, it is possible to shorten processing time to detect the position where the bit is 1 because mask processing and comparison need to be performed only once in order to determine a value per bit of data in the position where the bit is 1.
Further, Patent Literature 3 discloses the normalized data generation circuit that detects a bit position where a bit having a logical state different from that of the leading bit of input data appears first and then shifts the input data based on information representing the distance from the position of the decimal point of the input data to the detected bit position. Patent Literature 3 discloses that, according to the normalized data generation circuit, it is possible to shorten the time to generate normalized data because the most part of the shift operation can be performed in hardware.
However, none of Patent Literatures 2 and 3 disclose a technique to generate a bit string that contains bits indicating whether the values of adjacent bits are different or not for each pair of adjacent bits from a bit string that constitutes data to be normalized, as in the present invention.